AC_DEFUN([AC_CHECK_HOWTO], [
# check for $1
AC_ARG_WITH($1-root,
	[	--with-$1-root=DIR  $1 tree located in DIR],
	$2="$withval",
	$2=)

AC_MSG_CHECKING([how to link $1])

if test ".${$2}" != . ; then
	if test ! -f "${$2}/lib/$3" ; then
		AC_MSG_ERROR(["could not find "${$2}/lib/$3"])
	fi
   $2=`cd ${$2} && pwd`
else
	for i in /usr/local/$3 /usr /; do
		for ending in .a .so -m.a -m.so -m "" ; do
			if test -f "$i/lib/$3$ending" ; then
				$2=$i
				break
			fi
		done
		if test x$$2 != x; then
			break
		fi
	done
	if test ".$$2" = "." ; then
		AC_MSG_ERROR(["could not find $1 - need to install $3 maybe in lib$1-dev"])
	fi
fi
LIBNAME=`echo $3 |  sed -e 's/lib//' -e 's/\.a$//' -e 's/\.so$//'`
if test "$$2" = "/" -o "$$2" = "/usr"; then
	LIBS="${LIBS} -l$LIBNAME"
else
	LIBS="${LIBS} -L$$2/lib -l$LIBNAME"
	CPPFLAGS="${CPPFLAGS} -I$$2/include"
fi
AC_MSG_RESULT([$2 is $$2])
])

